package com.reviewit.model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import org.bson.types.ObjectId;

import com.google.code.morphia.annotations.Entity;
import com.google.code.morphia.annotations.Reference;

@Entity("users")
public class User extends UserBase implements Serializable {
	private static final long serialVersionUID = 1L;

	private Date birthdate;
	private String website;
	private String location;
	private String about;
	private String facebook;
	private String twitter;
	private String google;
	private String photo;

	@Reference(lazy = true)
	private Collection<Document> upVotes;
	@Reference(lazy = true)
	private Collection<Document> downVotes;
	@Reference(lazy = true)
	private Collection<User> following;
	@Reference(lazy = true)
	private Collection<Document> documents;

	public User() {
		super();
	}

	public User(ObjectId id) {
		super();
		this.id = id;
	}

	public User(ObjectId id, String firstName, String lastName, String email,
			String password, Collection<User> following, Date birthdate, String website,
			String location, String about, String facebookId, String twitterId,
			String googleId, String photo) {
		super();
		this.id = id;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.password = password;
		this.following = following;
		this.birthdate = birthdate;
		this.website = website;
		this.location = location;
		this.about = about;
		this.facebook = facebookId;
		this.twitter = twitterId;
		this.google = googleId;
		this.photo = photo;
	}

	public Collection<User> getFollowing() {
		return following;
	}

	public void setFollowing(Collection<User> following) {
		this.following = following;
	}

	public Date getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(Date birthdate) {
		this.birthdate = birthdate;
	}

	public String getWebsite() {
		return website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getAbout() {
		return about;
	}

	public void setAbout(String about) {
		this.about = about;
	}

	public String getFacebook() {
		return facebook;
	}

	public void setFacebook(String facebook) {
		this.facebook = facebook;
	}

	public String getTwitter() {
		return twitter;
	}

	public void setTwitter(String twitter) {
		this.twitter = twitter;
	}

	public String getGoogle() {
		return google;
	}

	public void setGoogle(String google) {
		this.google = google;
	}
	
	public String getPhoto() {
		return photo;//r@.
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	public Collection<Document> getUpVotes() {
		return upVotes;
	}

	public void setUpVotes(Collection<Document> upVotes) {
		this.upVotes = upVotes;
	}

	public Collection<Document> getDownVotes() {
		return downVotes;
	}

	public void setDownVotes(Collection<Document> downVotes) {
		this.downVotes = downVotes;
	}
	
	public Collection<Document> getDocuments() {
		return documents;
	}

	public void setDocuments(Collection<Document> documents) {
		this.documents = documents;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		// result = prime * result + (int) (id ^ (id >>> 32));
		result = prime * result;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (id != other.id)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return this.getFirstName() + " " + getLastName();
	}
}